package Game.Online.Messages 
{
	import flash.utils.ByteArray;
	import flash.utils.Endian;
	/**
	 * ...
	 * @author Yevgeniy Logachev
	 */
	public class Message 
	{
		private var m_type:int = -1;
		private var m_id:String = "";
		protected var m_data:ByteArray = null;
		public var m_isReceived:Boolean = false;
		
		public static const MSG_OFFSET_TYPE:int	= 0;
		public static const MSG_OFFSET_ID:int	= MSG_OFFSET_TYPE + 4; // 4 - sizeof(int)
		
		public function Message(type:int, id:String) 
		{
			m_type = type;
			m_id = id;
			
			m_data = new ByteArray();
			m_data.endian = Endian.LITTLE_ENDIAN;
			
			m_data.writeInt(type);
			m_data.writeUTF(id);
		}
		
		public function get type():int
		{
			return m_type;
		}
		
		public function get id():String
		{
			return m_id;
		}
		
		public function get data():ByteArray
		{
			return m_data;
		}
		
		public function set data(value:ByteArray):void
		{
			m_data = value;
		}
		
		public function get isReceived():Boolean
		{
			return m_isReceived;
		}
		
		public function set isReceived(value:Boolean):void
		{
			m_isReceived = value;
		}
	}

}